package com.sensetime.jv.controller;

import com.sensetime.jv.annotation.RequirePermission;
import com.sensetime.jv.entity.ReturnWrapper;
import com.sensetime.jv.service.CaptchaService;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/captcha")
@RequiredArgsConstructor
@Validated
public class CaptchaController {

    private final CaptchaService captchaService;

    @GetMapping("/generate")
    @RequirePermission(description = "获取验证码",whiteUrl = true)
    public ReturnWrapper<String> generate(@NotEmpty(message = "应用场景不能为空") String bizType, @NotEmpty(message = "目标用户不能为空") String target) {
        String image = captchaService.generate(bizType, target);
        return ReturnWrapper.success(image);
    }


}